// 验证全都是空格
const isAllSpaces = (str) => {
  return /^\s*$/.test(str);
};

// 对象分类算法
const group = (obj, pros) => {
  return obj.reduce((prev, item) => {
    let key = item[pros];
    if (!prev[key]) {
      prev[key] = [];
    }
    prev[key].push(item.tag);
    return prev;
  }, {});
};

// 拼接数组并去重
const concatAndRemoveDuplicates = (preArr, newArr) => {
  return [...new Set(preArr.concat(newArr))];
};

export { isAllSpaces, group, concatAndRemoveDuplicates };
